import java.util.HashSet;
import java.util.Set;

public class Test {
    private static final Set<Character> VOWELS = new HashSet<>();
    static {
        // 初始化元音集合
        VOWELS.add('a');
        VOWELS.add('e');
        VOWELS.add('i');
        VOWELS.add('o');
        VOWELS.add('u');
        VOWELS.add('A');
        VOWELS.add('E');
        VOWELS.add('I');
        VOWELS.add('O');
        VOWELS.add('U');
    }
    public String reverseVowels(String ss) {

        char[] s = ss.toCharArray();
        int left=0, right=s.length-1;
        while(left<right){
            if(!VOWELS.contains(s[left])){
                left++;
            }else if(!VOWELS.contains(s[right])){
                right--;
            }else{
                char temp = s[left];
                s[left] = s[right];
                s[right] = temp;
                left++;
                right--;
            }

        }
        return new String(s);
    }

    public static void main(String[] args) {
        Test test = new Test();
        System.out.printf(test.reverseVowels("leetcode"));
    }
}
